package com.lightbook.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lightbook.mapper.CartMapper;
import com.lightbook.pojo.Cart;
import com.lightbook.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CartServiceImpl extends ServiceImpl<CartMapper,Cart> implements CartService {

    @Autowired
    private CartMapper cartMapper;

    @Override
    public IPage selectPage(Page<Cart> pageNum, String keyword) {

        QueryWrapper<Cart> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("book_name", keyword)
                .or()
                .like("user_email", keyword)
                .orderByDesc("cart_id")
                ;
        return cartMapper.selectPage(pageNum, queryWrapper);
    }
}
